import { queryVideos } from '@/services/video';

export default {
  namespace: 'video',

  state: {
    videoList: [],
  },

  effects: {
    *queryVideoList({ payload }, { call, put }) {
      const response = yield call(queryVideos, payload.type, payload.page_size, payload.page_num);
      yield put({
        type: 'setVideoList',
        payload: {
          videoList: response ? response.data : [],
        },
      });
    },
  },

  reducers: {
    setVideoList(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
